<template>
  <ul class="todo-list">
    <!-- completed: 完成的类名 -->
    <!-- 遍历list -->
    <li :class="item.isDone ? 'completed' :''" v-for='item in list' :key='item.id'>
      <div class="view">
        <input class="toggle" type="checkbox" :checked='item.isDone' @change='changeFn(item.id)'/><!-- 改变事件@change='changeFn -->
        <label>{{item.name}}</label>
        <button class="destroy" @click='del(item.id)'></button>
      </div>
    </li>
  </ul>
  
</template>

<script>
export default {
  //接收数据
  props:{
    list:{
      type:Array,
      required:true
    }
  },

  methods:{
    del(id){
      this.$emit('del',id)
    },
    changeFn(id){
      this.$emit('change',id)

    }
  }
}
</script>